package com.itwenke.springbootdemo.shirosimple.demo;

import com.itwenke.springbootdemo.shirosimple.entity.BankAccount;
import com.itwenke.springbootdemo.shirosimple.service.IBankAccountService;
import com.itwenke.springbootdemo.shirosimple.utils.SpringBeanUtil;
import org.springframework.transaction.annotation.Transactional;

//@Component
public class NonBeanDemo {

    @Transactional(rollbackFor = Exception.class)
    public void addBankAccount(BankAccount bankAccount) throws Exception {
        IBankAccountService bankAccountService = SpringBeanUtil.getBean(IBankAccountService.class);
        bankAccountService.addBankAccount(bankAccount);
        throw new Exception("测试事务回滚");
    }
}
